package com.example.jiagoujiexiang.Service.impl;

import com.example.jiagoujiexiang.Mapper.adminDao;
import com.example.jiagoujiexiang.Mapper.commentDao;
import com.example.jiagoujiexiang.Service.adminService;
import com.example.jiagoujiexiang.Service.commentService;
import com.example.jiagoujiexiang.entity.Comment;
import com.example.jiagoujiexiang.entity.User;
import com.example.jiagoujiexiang.entity.subscribe;
import com.example.jiagoujiexiang.Mapper.commentDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class commentServiceimpl implements commentService {

    private final commentDao comment1;

    @Autowired
    public commentServiceimpl(commentDao comment1) {
        this.comment1 = comment1;
    }

    @Override
    public List<Comment> getCommentList() {
        return comment1.getCommentList();
    }

    @Override
    public int insertComment(String name, String comment) {
        return comment1.insertComment(name,comment);
    }
    @Override
    public int insertReply(int parentId, String name, String comment) {
        Comment newReply = new Comment();
        newReply.setNickname(name);
        newReply.setContent(comment);
        newReply.setTime(java.time.LocalDateTime.now().toString());
        newReply.setThumbUpCount(0);
        newReply.setParentId(parentId);
        return comment1.insertCommentR(newReply);
    }
}
